/**
 * <p>文件名:		MyIbatisDaoCallImpl.java</p>
 * <p>版权:		CopyrightTag</p>
 * <p>公司:		CompanyTag</p>
 * @author		周华彬(zhouhuabin@chinatransinfo.com, zhou_hua_bin@163.com)
 */

package com.caits.lbs.framework.dao.impl;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.sql.SQLException;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.dao.DataAccessException;

import com.caits.lbs.bean.dbmodel.ETBase;
import com.caits.lbs.framework.dao.IBusinessDAO;

/**
 * <p>
 * MyIbatisDaoCallImpl
 * </p>
 * <p>
 * TODO
 * </p>
 * @author 周华彬(zhouhuabin@chinatransinfo.com, zhou_hua_bin@163.com)
 * @version 0.0.0
 *          <table style="border:1px solid gray;">
 *          <tr>
 *          <th width="100px">版本号</th>
 *          <th width="100px">动作</th>
 *          <th width="100px">修改人</th>
 *          <th width="100px">修改时间</th>
 *          </tr>
 *          <!-- 以 Table 方式书写修改历史 -->
 *          <tr>
 *          <td>0.0.0</td>
 *          <td>创建类</td>
 *          <td>zhouhuabin</td>
 *          <td>2015年10月22日 上午9:58:52</td>
 *          </tr>
 *          <tr>
 *          <td>XXX</td>
 *          <td>XXX</td>
 *          <td>XXX</td>
 *          <td>XXX</td>
 *          </tr>
 *          </table>
 */
public class MyIbatisDaoCallImpl {

	/**
	 * 手动调用mybatis的例子  void
	 */
	public void init() {
		try {
			File file = new File("mybatis/xxxMapper.xml");
			FileReader reader = new FileReader(file);
			SqlSessionFactory sqlMapper = new SqlSessionFactoryBuilder().build(reader);
			SqlSession session = sqlMapper.openSession();
			//直接用session查询
			ETBase goods = (ETBase)session.selectOne("namespace.selectGoodById", 4);
		    //采用接口映射查询
			IBusinessDAO t = LocalMapperProxy.newMapperProxy(IBusinessDAO.class,session);
//			IBusinessDAO t = session.getMapper(IBusinessDAO.class);
			ETBase tt = t.queryBusiness("namespace.selectGoodById", null);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (DataAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
